package com.longdaji.decoration.ui.activitiesOfMine.housemaster.receiveIntegral;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.longdaji.decoration.R;
import com.longdaji.decoration.adapter.IntegralAdapter;
import com.longdaji.decoration.base.BaseActivity;
import com.longdaji.decoration.bean.Integral;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ReceiveIntegralActivity extends BaseActivity implements ReceiveIntegralContract.IView {

    @Inject
    ReceiveIntegralContract.IPresenter mPresenter;
    @BindView(R.id.tv_tool_title)
    TextView tvTitle;
    @BindView(R.id.rv_receive_integral)
    RecyclerView rvIntegral;

    private List<Integral> mIntegralList = new ArrayList<>();
    private IntegralAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_receive_integral);
        setUnBinder(ButterKnife.bind(this));
        if (mPresenter != null)
            mPresenter.setView(this);
        tvTitle.setText("领取积分");

        initView();
    }

    private void initView() {
        rvIntegral.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new IntegralAdapter(mIntegralList);
        rvIntegral.setAdapter(mAdapter);
        // TODO: 2018/4/7 0007 测试数据
        initList();
    }

    private void initList() {
        Integral integral = new Integral(50, 80, "自营饰品积分", "01/12 10:00", "已领取");
        mIntegralList.add(integral);
        Integral integral2 = new Integral(20, 50, "饰品耳环满减积分", "01/11 11:00", "领取");
        mIntegralList.add(integral2);
        Integral integral3 = new Integral(60, 50, "自营商品满减积分", "01/09 12:00", "已领取");
        mIntegralList.add(integral3);
        Integral integral4 = new Integral(60, 40, "耳环满减积分", "01/11 11:00", "已领取");
        mIntegralList.add(integral4);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null)
            mPresenter.detachView();
    }

    @OnClick({R.id.rl_tool_back})
    void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_tool_back:
                finish();
                break;
            default:
                break;
        }
    }
}
